import axios from "axios";
import { ElMessage } from "element-plus";

const service = axios.create({
  timeout: 10000
});

service.interceptors.request.use(config => {
  return config;
});

service.interceptors.response.use(response => {
  const { code, msg, data } = response.data;
  if (code !== 20000) {
    ElMessage.error(msg);
    return Promise.reject(msg);
  }
  return data;
});

export default service;
